<template>
	<div class="home">
		<div class="page-swipe">
			<mt-swipe :auto="4000">
				<!--在组件中，使用v-for循环的话，一定要使用key-->
				<mt-swipe-item v-for="item in lunbotuList" :key='item.img'>
					<img :src="item.img" class="img">
				</mt-swipe-item>

			</mt-swipe>
			<!--九宫格到六宫格的改造-->
			<ul class="mui-table-view mui-grid-view mui-grid-9">
				<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
					<router-link to="/home/newslist">
						<img src="../../assets/menu1.png">
						<div class="mui-media-body">新闻资讯</div>
					</router-link>
				</li>
				<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
					<router-link to="/newslist">
						<img src="../../assets/menu2.png">
						<div class="mui-media-body">图片分享</div>
					</router-link>
				</li>
				<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
					<router-link to="/newslist">
						<img src="../../assets/menu3.png">
						<div class="mui-media-body">商品购买</div>
					</router-link>
				</li>
				<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
					<router-link to="/newslist">
						<img src="../../assets/menu4.png">
						<div class="mui-media-body">留言反馈</div>
					</router-link>
				</li>
				<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
					<router-link to="/newslist">
						<img src="../../assets/menu5.png">
						<div class="mui-media-body">视频专区</div>
					</router-link>
				</li>
				<li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
					<router-link to="/contact">
						<img src="../../assets/menu6.png">
						<div class="mui-media-body">联系我们</div>
					</router-link>
				</li>

			</ul>
		</div>

	</div>
</template>

<script>
	//引入行为事件
	import { Toast } from 'mint-ui';
	export default {
		name: 'home',
		data() {
			return {
				lunbotuList: [] //保存轮播图的数组
			}
		},
		created() {
			this.getLunbotu()
		},
		methods: {
			getLunbotu() {
				this.$http.get('api/getlunbo').then(result => {
					//判断是否拿到数据，如果状态为0，代表成功
					if(result.body.status === 0) {
						//把获取到的数据进行赋值给data里的lunbotoList[]
						this.lunbotuList = result.body.message
						
					} else {
						Toast('加载轮播图数据失败');
					}
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.mint-swipe {
		height: 200px;
		.mint-swipe-item:first-of-type(1) {
			width: 100%;
		}
		.mint-swipe-item:nth-child(1) {
			width: 100%;
		}
		.mint-swipe-item:nth-child(2) {
			width: 100%;
		}
		.img {
			width: 100%;
			height: 200px;
		}
	}
	
	.mui-grid-view.mui-grid-9 {
		border: none;
		background-color: #fff;
		img {
			width: 60px;
			height: 60px;
		}
		.mui-media-body{
			font-zize:14px;
		}
	}
	
	.mui-grid-view.mui-grid-9 .mui-table-view-cell {
		border: none;
	}
</style>